package com.fulin.jdk8.date;

import java.time.DayOfWeek;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.TemporalUnit;
import java.util.Date;
import java.util.Locale;

import lombok.extern.java.Log;

/**
*
* @description 
* @auther fulin16@crnet.com.hk
* @since 2019年4月30日 上午9:29:14
*
*/
@Log
@Deprecated
public class UseDate {
	public static void main(String[] args) {
		LocalDate ld = LocalDate.now();
		log.info(ld.toString());
		LocalDate ld1 = ld.plusYears(1);
		LocalDate ld2 = ld.minusYears(2);
		log.info(ld1.toString());
		log.info(ld2.toString());
		Period until = ld1.until(ld2);
		log.info(until.toString());
		LocalDate withDayOfMonth = ld.withDayOfMonth(20);
		log.info(withDayOfMonth.toString());
		LocalDate withMonth = ld.withMonth(2);
		log.info(withMonth.toString());
		
		LocalDate with = ld.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
		log.info(with.toString());
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("d. M. y. E. Q",Locale.CHINA);
		log.info(ld.format(dtf));
		
		LocalDateTime ldt = LocalDateTime.now();
		log.info(ldt.toString());
		
		Date date = new Date();
		Instant instant = date.toInstant();
		ZoneId zoneId = ZoneId.systemDefault();
		
		LocalDateTime ldt1 = instant.atZone(zoneId).toLocalDateTime();
		log.info(ldt1.toString());
		
	}
}
